package org.ediba.siri.web.rest;

import java.text.SimpleDateFormat;
import java.util.Date;

import javax.servlet.http.HttpServletRequest;

import org.json.JSONObject;
import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.web.bind.ServletRequestDataBinder;
import org.springframework.beans.propertyeditors.StringArrayPropertyEditor;

public abstract class Controller extends org.springframework.web.servlet.mvc.multiaction.MultiActionController {

	@Override
	protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception {
		binder.registerCustomEditor(JSONObject.class, new JSONPropertyEditor());
		binder.registerCustomEditor(String[].class, "query", new org.ediba.siri.web.rest.StringArrayPropertyEditor(",", null, false, true, true));
		binder.registerCustomEditor(String[].class, new StringArrayPropertyEditor());
		binder.registerCustomEditor(Integer[].class, new IntArrayPropertyEditor());
		binder.registerCustomEditor(Date.class, new CustomDateEditor(new SimpleDateFormat("dd/MM/yyyy"), true, 10));
		binder.registerCustomEditor(Boolean.class, "dir" ,new BooleanPropertyEditor("ASC","DESC"));
	}
		
}